<%--
  Created by IntelliJ IDEA.
  User: 17230
  Date: 2020/6/29
  Time: 11:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <div>
        申报状态:
        <select id="status">
            <option value="-1">全部</option>
            <option value="0">已申报</option>
            <option value="1">审核中</option>
            <option value="2">已审核</option>
        </select>
        <input type="button" value="查询" id="btn">
    </div>

    <h1>申报列表</h1>
    <table>
        <tr>
            <td>项目编号</td>
            <td>项目名称</td>
            <td>申报开始日期</td>
            <td>申报结束日期</td>
            <td>申报状态</td>
        </tr>
    </table>
    
    <c:if test="${requesetScope.flag==1}">审核成功</c:if>
    <c:if test="${requesetScope.flag==0}">审核失败</c:if>
    <script src="js/jquery-1.8.3.js"></script>
    <script>
        $(function () {
            bindData();
            bindEvent()
        })
        
        function bindData() {
            $.post("ListProjectinfo",function(msg){
                var str ="";
               $(msg).each(function(i){
                   var p=msg[i]
                   str +="<tr>"
                   str +="<td>"+p.id+"</td>"
                   str +="<td>"+p.projetname+"</td>"
                   str +="<td>"+p.startdate+"</td>"
                   str +="<td>"+p.enddate+"</td>"
                   if(p.status==0){
                       str +="<td>已申报</td>"
                   }else if(p.status==1){
                       str +="<td>审核中</td>"
                   }else {
                       str +="<td>已审核</td>"
                   }

                   if(p.status!=2){
                       str +="<td><a href='findById?id="+p.id+"'>审核</a></td>"
                   }else {
                       str +="<td></td>"
                   }

                   str +="</tr>"
               })
                $("table").append(str)
            },"json")
        }


        function bindEvent(){
            $('#btn').click(function(){
              var status = $("#status").val();
                $.post("searchProjectinfo",{"status":status},function(msg){
                    var str ="";
                    $(msg).each(function(i){
                        var p=msg[i]
                        str +="<tr>"
                        str +="<td>"+p.id+"</td>"
                        str +="<td>"+p.projetname+"</td>"
                        str +="<td>"+p.startdate+"</td>"
                        str +="<td>"+p.enddate+"</td>"
                        if(p.status==0){
                            str +="<td>已申报</td>"
                        }else if(p.status==1){
                            str +="<td>审核中</td>"
                        }else {
                            str +="<td>已审核</td>"
                        }

                        if(p.status!=2){
                            str +="<td><a href='findById?id="+p.id+"'>审核</a></td>"
                        }else {
                            str +="<td></td>"
                        }

                        str +="</tr>"
                    })
                    $("table tr:not(:first)").remove()
                    $("table").append(str)
                },"json")

            })
        }
        
    </script>
</body>
</html>
